<template>
	<view class="nodata">
		<image src="@/static/images/nodata.png" mode=""></image>
		<text>{{ toast }}</text>
		<view v-if="isload && !is_location && !is_no_wifi" class="btn" @tap="reload">重新加载</view>
	</view>
</template>

<script>
	export default {
		props: {
			isload: {
				default: false,
			},
			toast: {
				default: "暂无数据",
			},
		},
		data() {
			return {
				is_location: false,
				is_no_wifi: false
			};
		},
		created() {
			const location = uni.getStorageSync("location");
			if (location) {
				this.is_location = true
			}
			uni.getNetworkType({
				success: (res) => {
					if (res.networkType !== "none") {
						this.is_no_wifi = true;
					}
				},
			});
		},
		methods: {
			reload() {
				this.$emit("reload")
			}
		}
	};
</script>

<style lang="scss" scoped>
	.nodata {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		image {
			width: 520rpx;
			height: 520rpx;
		}

		text {
			color: rgba(80, 80, 80, 1);
			font-size: 28rpx;
			margin-top: 24rpx;
		}
	}

	.btn {
		margin-top: 30rpx;
		width: 240rpx;
		height: 70rpx;
		padding: 0 20rpx;
		font-size: 28rpx;
		line-height: 70rpx;
		text-align: center;
		color: #ffffff;
		background: #38987c;
		border-radius: 7px;
	}
</style>